home *** CD-ROM | disk | FTP | other *** search
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
- /* Graphics3D.c
- /*
- /* 3D graphics and math routines
- /*
- /* Author: Michael Chen, Human Interface Group / ATG
- /* Copyright © 1991-1993 Apple Computer, Inc. All rights reserved.
- /*
- /* Part of Virtual Sphere Sample Code Release v1.1
- /*•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
-
- #ifndef __GRAPHICS3D__
- #define __GRAPHICS3D__
-
- #ifndef __GLOBALS__
- #include "Globals.h"
- #endif
-
- #ifndef __GRAF3D__
- #include <Graf3D.h>
- #endif
-
- #ifndef __MyMath__
- #include "MyMath.h"
- #endif
-
- #define Integer long
-
- typedef struct {
- Real x;
- Real y;
- Real z;
- } CPoint3D;
-
- typedef Real Matrix4D[4][4];
-
- typedef struct {
- Integer fVertexCount; /* Number of vertices in this polygon */
- Integer fFirstVertexIndex; /* Index into the fVertexIndices array */
- Integer fColorIndex; /* Index into the fColor array */
- } NetPolygon;
-
- typedef struct {
- Integer fPolygonCount; /* Number of NetPolygons in this structure */
- NetPolygon *fPolys; /* Array of NetPolygons */
- Integer fVertexCount; /* Number of vertices in this structure */
- Point3D *fVertices; /* Array of vertices */
- Integer *fVertexIndices; /* Array of vertex indices */
- RGBColor *fColor; /* Array of RGBColors */
- } PolygonNetData;
-
- pascal OSErr InitializeGraphics3D (void);
- pascal void FreeGraphics3D (void);
-
- pascal void CopyMatrix (Matrix4D fromMatrix, Matrix4D toMatrix);
- pascal void CrossProduct3D (const CPoint3D *a, const CPoint3D *b, CPoint3D *aCrossB);
- pascal Real DotProduct3D (const CPoint3D *a, const CPoint3D *b);
- pascal Real Length3D (const CPoint3D *a);
- pascal void Matrix2XfMatrix (Matrix4D fromMatrix, XfMatrix toMatrix);
- pascal void MultiplyMatrix (Matrix4D a, Matrix4D b, Matrix4D aTimesB);
- pascal void Normalize3D (CPoint3D *v);
- pascal void OrthogonalizeRotationMatrix (Matrix4D matrix);
- pascal void SetRotationMatrix (Matrix4D rotationMatrix, const CPoint3D *op, const CPoint3D *oq);
- pascal void UnitCrossProduct3D (const CPoint3D *a, const CPoint3D *b, CPoint3D *aCrossB);
-
- pascal void DrawPolyNet (const PolygonNetData *polyNet);
- pascal void PolyColor (const RGBColor *rGBColor);
-
- #endif __GRAPHICS3D__
-